<!--
  @author nowind
  @since 17/07/23 14:34
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head th:include="common/common :: jscss">
    <title>新增或编辑供应商</title>
</head>
<body>

<div class="layui-fluid">

    <blockquote class="layui-elem-quote layui-text">
        <a lay-href="/supplier/list.action">供应商管理</a>&nbsp;&nbsp;>&nbsp;
        <span th:text="${(supplier.supplierId == null||supplier.supplierId == 0) ? '新增供应商' : supplier.name}">新增或编辑供应商</span>
    </blockquote>

    <div class="layui-card">
        <form method="post" action="" class="layui-form" lay-filter="zmn-supplier-form">

            <input type="hidden" name="supplierId"/>

            <div class="layui-card-header"><b>基本信息</b></div>
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">供应商名称</label>
                    <div class="layui-input-inline" style="width:400px">
                        <input type="text" name="name" placeholder="请输入供应商名称"
                               lay-verify="required" autocomplete="off" class="layui-input" maxlength="50"/>
                    </div>
                </div>
                <div class="layui-form-item" style="width: 510px">
                    <label class="layui-form-label layui-form-required">所属公司</label>
                    <div class="layui-input-block">
                        <select name="companyId" id="companyId" lay-filter="companyId" lay-verify="required" lay-search>
                            <option value="">请选择</option>
                            <option th:each="companySimple:${companySimpleList}"
                                    th:value="${companySimple.value}"
                                    th:selected="${companySimple.value == supplier.companyId}"
                                    th:disabled="${!companySimple.status}"
                                    th:text="|${companySimple.text}${companySimple.status?'':'(已禁用)'}|">
                            </option>
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux" id="company-detail-div"></div>
                </div>
                <div class="layui-form-item" style="width: 510px">
                    <label class="layui-form-label">使用公司</label>
                    <div class="layui-input-block">
                        <select name="useCompanyId" id="useCompanyId" lay-filter="useCompanyId"  xm-select="useCompanyId" xm-select-search xm-select-search-type="dl">
                            <option value="">请选择</option>
                            <option th:each="companySimple:${platformCompanySimpleList}"
                                    th:value="${companySimple.value}"
                                    th:selected="${companyMapList.contains(companySimple.value)}"
                                    th:disabled="${!companySimple.status}"
                                    th:text="|${companySimple.text}${companySimple.status?'':'(已禁用)'}|">
                            </option>
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline" style="width:400px;">
                        <textarea name="remark" placeholder="请输入备注" class="layui-textarea" maxlength="100"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status"
                               lay-verify="statusRadio"
                               th:each="status:${statuses}"
                               th:value="${status.key}"
                               th:checked="${status.key == supplier.status}"
                               th:title="${status.value}">
                    </div>
                </div>
                <!--<div class="layui-form-item" th:if="${#authPermit.checkPermit('supplier-supplierType')}">-->
                    <!--<label class="layui-form-label layui-form-required">供应商类型</label>-->
                    <!--<div class="layui-input-block">-->
                        <!--<input type="radio" name="type"-->
                               <!--th:each="supplierType:${supplierTypeList}"-->
                               <!--th:value="${supplierType.key}"-->
                               <!--th:checked="${supplierType.key == supplier.type}"-->
                               <!--th:title="${supplierType.value}">-->
                    <!--</div>-->
                <!--</div>-->
                <div class="layui-split">&nbsp;</div>
                <div class="layui-form-item layui-layout-admin"
                     th:if="${#authPermit.checkPermit('/supplier/ajax/addEdit.action')}">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn" lay-submit lay-filter="save" id="save">保存</button>
                            <button class="layui-btn layui-btn-primary" type="button" id="cancel">取消</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>

    </div>

</div>
<script type="text/javascript" th:inline="javascript">
    let json = {
        items: [[${supplier}]],
        companyMapList: [[${companyMapList}]],
        platformCompanySimpleList: [[${platformCompanySimpleList}]]
    };


    layui.config({
        base: "/static/lay/"
    }).extend({
        index: "lib/index",
        formSelects: '{/}/static/lay/layui/formSelects-v4',
        scm_supplier_edit: "{/}/static/js/module/supplier/zmn.scm.scmsupplier.edit"
    }).use(['index', 'scm_supplier_edit','formSelects']);

</script>
</body>
</html>